package 笔试;

public class 每隔三位添加点 {
    public String thousandSeparator(int n) {
        Integer num = n;
        String s = num.toString();
        StringBuilder sb = new StringBuilder();
        int i = s.length()-1;
        while(i >= 0) {
            for(int j = 0; j < 3; j++) {
                if(i < 0) {
                    break;
                }
                sb.append(s.charAt(i));
                if(i >= 0) i--;
            }

            if(i < 0) {
                break;
            } else {
                sb.append(".");
            }


        }
        StringBuilder res = sb.reverse();

        return res.toString();
    }
}
